﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Box2 : Box
{
    // Start is called before the first frame update
    protected override void Start()
    {
        base.Start();
    }

    // Update is called once per frame
    void Update()
    {
        Movement();
    }

    private void OnCollisionEnter2D(Collision2D collision)
    {
        Transform player = collision.transform;

        if (collision.gameObject.tag == "Player" && player.position.y > transform.position.y)
        {
            StartCoroutine(RemoveBox());
        }
    }

    IEnumerator RemoveBox()
    {
        yield return new WaitForSeconds(0.1f);

        Destroy(gameObject);
    }
}
